<template>
  <a-select
    show-search
    option-filter-prop="children"
    :placeholder="$t('pleaseSelect') + $t('isEnable').toLowerCase()"
    :allow-clean="allowClean"
    :mode="mode"
    v-model="selectedValue"
  >
    <a-select-option v-for="item in options" :key="item.id" :value="item.id">
      {{ $t(item.name) }}
    </a-select-option>
  </a-select>
</template>
<script>
export default {
  props: {
    defaultValue: {
      type: [Number, Boolean],
      default () {
        return undefined
      }
    },
    mode: {
      type: String,
      default: 'default'
    },
    allowClean: {
      type: Boolean,
      default: false
    }
  },
  data () {
    return {
      selectedValue: true,
      options: [{
        id: 1,
        name: 'start'
      }, {
        id: 0,
        name: 'disabled'
      }]
    }
  },
  watch: {
    defaultValue: {
      handler (val) {
        if (val * 1 !== this.selectedValue) {
          this.selectedValue = val * 1
        }
      },
      immediate: true
    },
    selectedValue (val) {
      if (val * 1 === this.defaultValue * 1) {
        return
      }
      this.$emit('changeoption', val)
    }
  },
  created () {
  },
  methods: {
  }
}
</script>
